

var pageContext = new PageContextBsgrid(settings||{});
pageContext.formInit = function(layero){
	var val = layero.find("select[name='categoryCode']").find("option:selected").text();
	layero.find("input[name='categoryName']").val(val);
	layero.find("select[name='categoryCode']").on("change",function(){
		var me = this;
		var val = $(this).find("option:selected").text();
		layero.find("input[name='categoryName']").val(val)
	});
}
pageContext.renderAddPageOther = function(layero,data,para,option){
};
pageContext.renderUpdatePageOther = function(layero,data,para,option){
	
    
	layero.find("select[name='categoryCode']").attr("oldval",data.categoryCode).find("option[value='"+data.categoryCode+"']").attr("selected",true);
    tvc.changeDefaultValue(layero.find("select[name='categoryCode']").get(0));
	
}

pageContext.getOtherOperBtn = function(id,label,record){
	var html = [];	
	return html.join("");
}
pageContext.getOtherPingPuOperBtn = function(id,label,record){
	var html = [];
	return html.join("");
}
pageContext.renderAfterEventOther = function(){
	$('#'+pageContext.setting.tableId+' >tbody > tr > td').delegate(".propBtn","click",function(e){
		 var val = $(this).attr("val");
		 var label = $(this).attr("label");
		 var url = ($(this).attr("url"));
		 $("#newPage").closest("a").attr("href",url);
		 $("#newPage").click();
	     return false;
	});
}
pageContext.toAdd = function(me){
	window.location=window.global.ctx+"/info/company/toadd";
} 
pageContext.toUpdate = function(id,data){
	window.location=window.global.ctx+"/info/company/toedit?id="+id;
}
pageContext.toDetail = function(id,data){
	window.location=window.global.ctx+"/info/company/todetail?id="+id;
}
pageContext.resetAfter = function (){
	$('#searchForm select[name="categoryCode"]').change();
	$('#searchForm select[name="targetCode"]').change();
}
function operateSex(record, rowIndex, colIndex, options){
	var val = record.sex;
	if(val===true){
		return "男";
	}else if(val===false){
		return "女";
	}
	return "未知"
}
jQuery(function($) {
   pageContext.init();
   if(!ace.vars['touch']) {
		$('#searchForm select').chosen({allow_single_deselect:true}); 
		//resize the chosen on window resize
		$(window)
		.off('resize.chosen')
		.on('resize.chosen', function() {
			$('.chosen-select').each(function() {
				 var $this = $(this);
				 $this.next().css({'width': $this.parent().width()});
			})
		}).trigger('resize.chosen');
		//resize chosen on sidebar collapse/expand
		$(document).on('settings.ace.chosen', function(e, event_name, event_val) {
			if(event_name != 'sidebar_collapsed') return;
			$('.chosen-select').each(function() {
				 var $this = $(this);
				 $this.next().css({'width': $this.parent().width()});
			})
		});
	}
}); 
